import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 游游的重组偶数
 * User: wangxin
 * Date: 2024-09-27
 * Time: 10:51
 */
public class test1 {
    public static int num(int x){
        String str = String.valueOf(x);
        StringBuffer strb = new StringBuffer(str);
        boolean fature = false;
        for(int i = 0;i < strb.length();i++){
            if(strb.charAt(i) % 2 == 0){
                char tmp = strb.charAt(i);
                strb.setCharAt(i,strb.charAt(strb.length() - 1));
                strb.setCharAt(strb.length() - 1,tmp);
                fature = true;
                break;
            }

        }
        if(!fature){
            return -1;
        }
        str = strb.toString();
        int ret = Integer.parseInt(str);
        return ret;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

        int q = in.nextInt();
        int[] arr = new int[q];
        for(int i = 0;i < q;i++){
            int x = in.nextInt();
            if(x % 2 == 0){
                arr[i] = x;
            }else{
                arr[i] =  num(x);
            }
        }
        for(int i = 0;i < q;i++){
            System.out.println(arr[i]);
        }

    }
}
